<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>医疗门诊</title>
<script type="text/javascript" src="static/easyui/jquery.min.js"></script>
<script type="text/javascript" src="static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
<link rel="stylesheet" href="static/easyui/themes/metro/easyui.css"/>
</head>
<body>
<script type="text/javascript">

//转换日期格式
function formatDate(date) { 
	var year = date.getFullYear(); 
	var month = date.getMonth() + 1; 
	var day = date.getDate(); 
	var hour = date.getHours(); 
	var minute = date.getMinutes(); 
	var second = date.getSeconds(); 
	return year + "-" + formatTen(month) + "-" + formatTen(day); 
}

function formatTen(num) { 
	return num > 9 ? (num + "") : ("0" + num); 
}
        
$(function(){
        	 var tab;
        	 var title;
        	 var curdate = new Date();
        	 var curdate_format=formatDate(curdate);
        	 //病历本---看诊记录
        	$(".lookdoctor-book").click(function(){
        		var clinic_card=$("#lookdoctor-sickuserlbox-sreachbox").textbox("getValue");
        		if(clinic_card!=""){
        			//打开窗口
        			$("#lookdoctor-book-win").window('open');
        			tab=$('.ttabs').tabs('getSelected');
        		    title=tab.panel('options').title;
        		    //给搜索框赋值
        		    $("#look-patient-date").datebox("setValue",curdate_format);
        		    
        			 //看诊记录表格---根据医疗卡号查询
        			//alert("clinic_card000--------:"+clinic_card);
        			$("#look-patientsRecord-tab").datagrid({
        			   		 url:'lookdoctor-sickrecord?clinic_card='+clinic_card,
    	    			   	 pagination:true,
    	    	      		 pageNumber:1,
    	    	      		 pageSize:7,
    	    	      		 pageList:[7,8],
        			   		 columns:[[
        							{field:'section_name',title:'科室',width:100},
        							{field:'lookiness_reason',title:'病因',width:146.6},
        							{field:'lookiness_result',title:'结果',width:145.6},
        							{field:'lookiness_time',title:'看诊时间',width:127.6,formatter:comFormatDate}
        			       ]]
        			});
        			
        			
        			 //体检记录---根据医疗卡号查询
        			//alert("clinic_card000--------:"+clinic_card);
        			$("#look-patientsHealth-tab").datagrid({
        			   		 url:'lookdoctor-healthrecord?clinic_card='+clinic_card,
    	    			   	 pagination:true,
    	    	      		 pageNumber:1,
    	    	      		 pageSize:7,
    	    	      		 pageList:[7,8],
        			   		 columns:[[
        							{field:'section_name',title:'科室',width:100},
        							{field:'project_name',title:'体检项目',width:146.6},
        							{field:'health_result',title:'体检结果',width:145.6},
        							{field:'health_times',title:'体检时间',width:127.6,formatter:comFormatDate}
        			       ]]
        			});
        			
        		}else{
        			 $.messager.confirm('Confirm', 
								'你未选择病人,请打开医疗卡的搜索框双击选择！', 
								function(r){
					     });
        		}
        	});
			
			
			
				//看诊病历本日期查询
				$(".look-patient-date-btn").click(function(){
					//alert("title------------"+title);
					if(title="看诊记录"){
						 var clinic_card=$("#lookdoctor-sickuserlbox-sreachbox").textbox("getValue");
						 var dates=$("#look-patient-date").datebox("getValue");
						 //alert("clinic_card"+clinic_card+"---dates----"+dates);
						 $("#look-patientsRecord-tab").datagrid({
		  			   		    url:'Searchlookdoctor-sickrecord?clinic_card='+clinic_card+"&lookdate="+dates,
			    			   	 pagination:true,
			    	      		 pageNumber:1,
			    	      		 pageSize:7,
			    	      		 pageList:[7,8],
		    			   		 columns:[[
		    							{field:'section_name',title:'科室',width:100},
		    							{field:'lookiness_reason',title:'病因',width:146.6},
		    							{field:'lookiness_result',title:'结果',width:145.6},
		    							{field:'lookiness_time',title:'看诊时间',width:127.6,formatter:comFormatDate}
		    			       ]]
						});
					}
					
					if(title="体检记录"){
						 var clinic_card=$("#lookdoctor-sickuserlbox-sreachbox").textbox("getValue");
						 var dates=$("#look-patient-date").datebox("getValue");
						 $("#look-patientsHealth-tab").datagrid({
					   		 url:'Searchlookdoctor-healthrecord?clinic_card='+clinic_card+"&lookdate="+dates,
		    			   	 pagination:true,
		    	      		 pageNumber:1,
		    	      		 pageSize:7,
		    	      		 pageList:[7,8],
					   		 columns:[[
									{field:'section_name',title:'科室',width:100},
									{field:'project_name',title:'体检项目',width:146.6},
									{field:'health_result',title:'体检结果',width:145.6},
									{field:'health_times',title:'体检时间',width:127.6,formatter:comFormatDate}
					       ]]
					    });
					}
				});
			
        	 
        	 
        	//申请住院
     		$(".apply-insicker").click(function(){
     			 var lid=$("#lillnessid").val();
     			 if(lid!=""){
     				 /* alert(lid); */
         		     $.ajax({
         		    	 url:'apply-hospital',
         		    	 type:'post',
         		    	 data:{"lid":lid},
         		    	 success:function(data){
         		    		//看诊号
         		         	$("#quick-uclickcard").textbox('setValue',lid); 
         		 			//姓名
         		 			$("#quick-unames").textbox('setValue',data[0]['clinic_name']); 
         		 			//性别
         		 			 $("#quick-usex").combobox('setValue',data[0]['clinic_sex']);
         		 			//身份证号
         		 			$("#quick-ucard").textbox('setValue',data[0]['clinic_idnumber']); 
         		 			//病因
         		 			$("#quick-ureason").textbox('setValue',data[0]['lookiness_reason']); 
         		 			//手机号码
         		 			$("#quick-utel").textbox('setValue',data[0]['clinic_tel']); 
         		 			//科室
         		 			$("#quick-usection").textbox('setValue',data[0]['section_name']); 
         		 			//医生
         		 			$("#quick-udocname").textbox('setValue',data[0]['registr_docname']);
         		 			
         		    		$("#quick-lookdoctor-win").window('open');
         		    	 }
         		     });
     				 
     			 }else{
     				 $.messager.confirm('Confirm', 
                  			'未选择病人,不能直接打开' , 
   							function(r){
   					  });
     			 }
     			
     			
     		});
        	 
        	//住院申请提交
        	$("#submit-quick-lookdoctor").click(function(){
        		 $("#quick-lookdoctor").form({
        			 url:'add-applyHospital',
        			 onSubmit:function(){
        				  var c=$('#quick-lookdoctor').form("validate");
        				   return c;
        			 },
        			 success:function(data){
        				 $(".window-tishi").text("住院申请成功！！！");
					    	$("#saveclinic-win").window('open');
					    	//三秒之后自动消失
						   setTimeout(function(){
						    	 $("#saveclinic-win").window('close');
							}, 3000);
        				  $('#quick-lookdoctor').form('clear');
        				  //关闭窗口
        				  $("#quick-lookdoctor-win").window('close');
        			 }
        			 
        		 }).submit();  
        		 
        	});
        	
        	//体检项目追加按钮
        	$("#lookcheckhealth-addsubmit").click(function(){
				//获取表格中的信息
				var rows =$("#lookchekuphealth-tabs").datagrid('getSelections');
				var copyRows = [];
	            for (var j= 0; j < rows.length; j++) {
	                copyRows.push(rows[j]); //将数据添加到copyRows数组中     
	            }
	            for(var i =0;i<copyRows.length;i++){ 
					var falg = true;
					var index = $('#lookchekuphealth-tabs').datagrid('getRowIndex',copyRows[i]);
					//获取追加的表格的行
					var recordrows = $("#doclookchekuphealth-tabs").datagrid("getRows");
					for(var m=0;m<recordrows.length;m++){
					     //判断该datagrid在将要添加的数据中是否存在
					     if(copyRows[i].project_no == recordrows[m].project_no){					      
					        	falg = false;
					     }
					} 
	                 if(falg){
	                	 $("#doclookchekuphealth-tabs").datagrid('appendRow',{
	                		 project_no:rows[i].project_no,
	                		 project_name:rows[i].project_name,
	                		 project_price:rows[i].project_price
		 		         });
	                 }
	            }
	            //清除所有所选的项
		        $("#lookchekuphealth-tabs").datagrid('clearChecked');	
			});
        	
        	//体检项目添加
        	 $('#doclookchekuphealth-tabs').datagrid({
      		    url:'',
      		    pagination:true,
      		    pageNumber:1,
      		    pageSize:3,
      		    pageList:[1,3],
      		    columns:[[
      		    	   {field:'project_no',title:'  ',width:40,checkbox:true,hidden:true},
    		    	   {field:'project_name',title:'项目名称',width:450},
    				   {field:'project_price',title:'项目价格',width:430},
    				   {field:'project_remove',title:'操作',width:88,align:'center',
							formatter:function(value,row,index){
								 return  "<a onclick='project_remove("+row.project_no+")'>移除</a>"
								
							}	
    				   }
      		    ]]
      		});
        	 
        	//体检的确定按钮
 			$("#doclookcheckhealth-addsubmit").click(function(){
 			/* 	alert("体检项目！！！！"); */
 				//获取看诊号
 				var look_id = $("#lillnessid").val();
 				
 				//获取体检项目的编号
 				var project_rows = $("#doclookchekuphealth-tabs").datagrid('getRows');
 				console.log(project_rows);
 				//项目编号的数组
 				var project_arr = [];
 				//项目的总金额
 				var totalmoney=null;
 				for(var i=0;i<project_rows.length;i++){
 					project_arr.push(project_rows[i].project_no);
 					totalmoney +=project_rows[i].project_price;
 				}
 				parseFloat(totalmoney);
 				$.ajax({
 					url:'outadd-health?project_arr='+project_arr+'&look_id='+look_id+'&totalmoney='+totalmoney,
 					method:'Post',
 					Type:'json',
 					success:function(data){
 						 $(".window-tishi").text("体检项目添加成功！！！");
					    	$("#saveclinic-win").window('open');
					    	//三秒之后自动消失
						   setTimeout(function(){
						    	 $("#saveclinic-win").window('close');
							}, 3000);
 					}
 				});
 				console.log("循环的数据："+project_arr);
 				//清除选项
 				$("#lookchekuphealth-tabs").datagrid('clearChecked');
 				$("#doclookchekuphealth-tabs").datagrid("loadData", {total:0, rows:[]});
 			});  
             	
      			//根据医疗卡填充信息
      			 $("#lookdoctor-sickuserlbox-sreachbox").searchbox({
      				 searcher:function(value,name){
      					    var rowd=	$("#clinic-record-tab").datagrid("getRows");
      					    if(rowd.length==0){
      					    	 $.messager.confirm('Confirm', 
 		     							'暂无病人(原因：权限不足或者不是病人所挂医生)', 
 		     							function(r){
      					    		    
 		     							}
      					    	 );
      					    }else{
      						$("#clinic-record-win").window("open");
      					    
      					 }
      				 }
      			 });
      			
      			 //初始化网格内容
	      			$("#clinic-record-tab").datagrid({
	      			    url:'lookdoctor-cliniccardid',
		      			pagination:true,
		 	      		pageNumber:1,
		 	      		pageSize:8,
		 	      		pageList:[8,9],
	      			    columns:[[
	      			        	{field:'docadvice_id',title:'医嘱主键id',hidden:true},
	      			  			{field:'docadvice_conent',title:'医嘱内容',hidden:true},
	      			  			{field:'lookiness_result',title:'看诊结果',hidden:true},
	      			  			{field:'lookiness_reason',title:'病因',hidden:true},
	      			    	    {field:'clinic_id',title:'医疗卡编号',hidden:true},
	      			    	 	{field:'cliniccard_id',title:'医疗卡号',width:125},
	      			    	 	{field:'registr_id',title:'挂号id',hidden:true},
	      			    		{field:'clinic_name',title:'病人姓名',width:100},
	      						{field:'clinic_sex',title:'性别',width:58},
	      						{field:'clinic_idnumber',title:'身份证号',width:150},
	      						{field:'clinic_tel',title:'电话',width:120},
	      						{field:'section_id',title:'科室编号',hidden:true},
	      						{field:'section_name',title:'科室',width:101},
	      						{field:'uid',title:'医生编号',hidden:true},
	      						{field:'registr_docname',title:'挂号医生',width:100}
	      			    ]]
	      			});
      			
      			//双击文本框网格
      			$("#clinic-record-tab").datagrid({
					onDblClickRow: function(rowIndex,rowData){
						     //登录人id
						     var loginuserid=$("#userId").val();
						     //登录人名字
						     var loginusername=$("#userName").val();
						    //分诊医生id
						     var triageuserid=rowData["uid"] 
						     console.log("登录人id:"+loginuserid+"---------登录人名字:"+loginusername+"---------分诊医生id:"+triageuserid);
						     //如果登录人id！=接诊医生id-->看诊获取的医生名字就是登录人
						     if(loginuserid!=triageuserid){
						    	 console.log("登录人id!=接诊医生id----------进入");
						    	     //登录人为医生
		  		                    $("#lookdoctor-sickdoctor").textbox('setValue',loginusername);
		  		                    //登录用户id
		  		                    $("#userid").val(loginuserid);
		  		                    
		  					        //医疗卡
		  		                    $("#lookdoctor-sickuserlbox-sreachbox").textbox('setValue',rowData['cliniccard_id']); 
		  		                    //$("#lookdoctor-sickuserlbox-sreachbox").textbox("readonly","true");
							  	 	//医疗卡主键
		  		                     $("#ld_clinicid").val(rowData['clinic_id']); 
		  		                    //挂号id
		  		                     $("#ld_registrid").val(rowData['registr_id']); 
		  		                    //患者姓名
		  		                     $("#lookdoctor-sickuname").textbox('setValue',rowData['clinic_name']); 
		  		                    //患者性别
		  		                    $("#lookdoctor-sickusex").combobox('setValue',rowData['clinic_sex']);
		  		                    //身份证号
		  		                    $("#lookdoctor-sickusercard").textbox('setValue',rowData['clinic_idnumber']);
		  		                    //手机号码
		  		                    $("#lookdoctor-sickuserTel").textbox('setValue',rowData['clinic_tel']);
		  		                    //科室
		  		                    $("#lookdoctor-sicksection").textbox('setValue',rowData['section_name']);
		  		                    $("#lookdoctor-sectionid").textbox('setValue',rowData['section_id']);
		  		                   
		  		               		 //医嘱内容
		  		              	     $("#lookdoctor-advicecomment").textbox('setValue',rowData['docadvice_conent']);
		  		                 	//诊断结果
									$("#lookdoctor-results").textbox('setValue',rowData['lookiness_result']);
									//病因
									$("#lookdoctor-reason").textbox('setValue',rowData['lookiness_reason']);
									
									//病历本
									//医疗卡
		  		                    $("#lclinic_cardid").textbox('setValue',rowData['cliniccard_id']); 
		  		                    //患者姓名
	  		                        $("#luname").textbox('setValue',rowData['clinic_name']); 
	  		                        //患者性别
	  		                        $("#lusex").combobox('setValue',rowData['clinic_sex']);
	  		                       //身份证号
	  		                       $("#luserID").textbox('setValue',rowData['clinic_idnumber']);
	  		                       //手机号码
	  		                      $("#lusertel").textbox('setValue',rowData['clinic_tel']);
						     }
						   
						     if(loginuserid==triageuserid){
						    	     console.log("分诊医生本人进入！！！！");
						    	    //医疗卡
		  		                    $("#lookdoctor-sickuserlbox-sreachbox").textbox('setValue',rowData['cliniccard_id']); 
		  		                    $("#lookdoctor-sickuserlbox-sreachbox").textbox("readonly","true");
							  	 	//医疗卡主键
		  		                     $("#ld_clinicid").val(rowData['clinic_id']); 
		  		                    //挂号id
		  		                     $("#ld_registrid").val(rowData['registr_id']); 
		  		                    //患者姓名
		  		                     $("#lookdoctor-sickuname").textbox('setValue',rowData['clinic_name']); 
		  		                    //患者性别
		  		                    $("#lookdoctor-sickusex").combobox('setValue',rowData['clinic_sex']);
		  		                    //身份证号
		  		                    $("#lookdoctor-sickusercard").textbox('setValue',rowData['clinic_idnumber']);
		  		                    //手机号码
		  		                    $("#lookdoctor-sickuserTel").textbox('setValue',rowData['clinic_tel']);
		  		                    //科室
		  		                    $("#lookdoctor-sicksection").textbox('setValue',rowData['section_name']);
		  		                    $("#lookdoctor-sectionid").textbox('setValue',rowData['section_id']);
		  		                	//医生
		  		                    $("#lookdoctor-sickdoctor").textbox('setValue',rowData['registr_docname']);
		  		                    //用户id
		  		                    $("#userid").val(rowData["uid"]);
		  		                   
		  		                    //医嘱内容
		  		              	    $("#lookdoctor-advicecomment").textbox('setValue',rowData['docadvice_conent']);
		  		                 	//诊断结果
									$("#lookdoctor-results").textbox('setValue',rowData['lookiness_result']);
									//病因
									$("#lookdoctor-reason").textbox('setValue',rowData['lookiness_reason']);
									
									//病历本
									//医疗卡
		  		                    $("#lclinic_cardid").textbox('setValue',rowData['cliniccard_id']); 
		  		                    //患者姓名
	  		                        $("#luname").textbox('setValue',rowData['clinic_name']); 
	  		                        //患者性别
	  		                        $("#lusex").combobox('setValue',rowData['clinic_sex']);
	  		                       //身份证号
	  		                       $("#luserID").textbox('setValue',rowData['clinic_idnumber']);
	  		                       //手机号码
	  		                      $("#lusertel").textbox('setValue',rowData['clinic_tel']);
						     }
	  		                   //关闭窗口
	  		                  $("#clinic-record-win").window("close");
					}
      			
			});
        	 
        	 //药物初始化
        	 $('#drug-tab').datagrid({
 			    url:'findall-outdrug',
 			    pagination:true,
 			    pageNumber:1,
 			    pageSize:3,
 			    pageList:[2,3],
 			    columns:[[
 			    	 	{field:'drug_number',title:'药品编号',width:120,checkbox:true},
 			    	 	{field:'category_name',title:'药品类别',width:163},
 			    		{field:'type_name',title:'药品类型',width:167},
 						{field:'drug_name',title:'药品名称',width:187},
 						{field:'drug_retail_price',title:'药品单价',width:127},
 						{field:'drug_standard',title:'药品规格',width:167},
 						{field:'drug_unit',title:'单位',width:129}
 			    ]]
 			});
        	 
        	 //药物查询
        	$("#search-checkdrugname").searchbox({
				searcher:function(value){
				/* 	alert(value); */
					//访问数据源、初始化表格
					$('#drug-tab').datagrid({
					    url:'findall-outdrug',
					    queryParams:{
					    	drugname:value 
					    },
					    pagination:true,
					    pageNumber:1,
					    pageSize:3,
					    pageList:[1,3],
					    columns:[[
					    	{field:'drug_number',title:'药品编号',width:120,checkbox:true},
	 			    	 	{field:'category_name',title:'药品类别',width:163},
	 			    		{field:'type_name',title:'药品类型',width:167},
	 						{field:'drug_name',title:'药品名称',width:187},
	 						{field:'drug_retail_price',title:'药品单价',width:127},
	 						{field:'drug_standard',title:'药品规格',width:167},
	 						{field:'drug_unit',title:'单位',width:129}
					    ]]
					});
				}
			});
        	 
        	 //体检项目
        	  $('#lookchekuphealth-tabs').datagrid({
      		    url:'findall-outhealthproject',
      		    pagination:true,
      		    pageNumber:1,
      		    pageSize:3,
      		    pageList:[1,3],
      		    columns:[[
      		    	   {field:'project_no',title:'  ',width:40,checkbox:true},
    		    	   {field:'project_name',title:'项目名称',width:500},
    				   {field:'project_price',title:'项目价格',width:440}
      		    ]]
      		});
        	 
        	 
        	  //体检项目查询
          	$("#search-checkhospname").searchbox({
  				searcher:function(value){
  					/* alert(value); */
  					//访问数据源、初始化表格
  					$('#lookchekuphealth-tabs').datagrid({
  						url:'findall-outhealthproject',
  					    queryParams:{
  					    	projectname:value 
  					    },
  					    pagination:true,
  					    pageNumber:1,
  					    pageSize:3,
  					    pageList:[1,3],
  					    columns:[[
  					    	 {field:'project_no',title:'  ',width:40,checkbox:true},
  	    		    	     {field:'project_name',title:'项目名称',width:500},
  	    				     {field:'project_price',title:'项目价格',width:440}
  					    ]]
  					});
  				}
  			});
        	 
        	 //医疗项目
        	  $('#hospitalproject-tab').datagrid({
        		    url:'select-hospitalhproject',
        		    pagination:true,
        		    pageNumber:1,
        		    pageSize:3,
        		    pageList:[3,6],
        		    columns:[[
        		    	    {field:'hospital_project_id',title:'',width:40,checkbox:true},
        		    	 	{field:'hospital_project_name',title:'项目名称',width:500},
        					{field:'hospital_project_price',title:'项目价格',width:440}
        		    ]]
        		});
        	 
        	 
        	 //医疗项目查询
        	$("#search-checkyilname").searchbox({
				searcher:function(value){
					/* alert(value); */
					//访问数据源、初始化表格
					$('#hospitalproject-tab').datagrid({
					    url:'select-hospitalhproject',
					    queryParams:{
					    	hprojectname:value 
					    },
					    pagination:true,
					    pageNumber:1,
					    pageSize:3,
					    pageList:[1,3],
					    columns:[[
					    	    {field:'hospital_project_id',title:'',width:40,checkbox:true},
	        		    	 	{field:'hospital_project_name',title:'项目名称',width:500},
	        					{field:'hospital_project_price',title:'项目价格',width:440}
					    ]]
					});
				}
			});
        	 
        	 //安排手术
  			$("#out-arrange-op").click(function(){
  				$("#outarrange-ops-win").window("open");
  			});
        	 
        	 //看诊提交---新增
			$("#save-lookilness").click(function(){
				var ssd=$("#lookdoctor-sickuserlbox-sreachbox").textbox("getValue");
				if(ssd!=""){
					//获取挂号id----查出最新的看诊记录------获取看诊号
					  var registr_id=$("#ld_registrid").val();
					  $.ajax({
							url:'lookdoctor-redo?registr_id='+registr_id,
							type:'post',
							dataType:'json',
							success:function(data){
								console.log("data-------"+data);
								if(data==2){
									console.log("没有查到看诊号了！！！");
									 //看诊保存
									$("<form method='post' id='lookfrom'>").appendTo("body").form({
										url:'add-lookillness',
										onSubmit:function(param){
											//获取看诊信息--新增看诊
											//医疗卡id----param["vo类的名字.对应实体类的名字"]
											param["look.clinicCard.clinicId"] = $("#ld_clinicid").val();
											console.log(param["look.clinicCard.clinicId"]=$("#ld_clinicid").val());
										    //挂号id
										    param["look.registrFrom.registrId"] = $("#ld_registrid").val();
										    console.log("挂号id--------:");
										    console.log(param["look.registrFrom.registrId"]=$("#ld_registrid").val());
										    console.log("挂号id--------end");
										    //医生id
										    param["look.user.userId"] = $("#userid").val();
										    console.log( "医生id1111----------");
										    console.log( param["look.user.userId"] = $("#userid").val());
										    console.log( "医生id1111----------");
											//看诊状态---0看诊完 1看诊中 2看诊完
											param["look.lookinessState"] = $("#look_state").val();
											console.log(param["look.lookinessState"]=$("#look_state").val());
										   //病因
										   param["look.lookinessReason"] = $("#lookdoctor-reason").val();
										   console.log(param["look.lookinessReason"]=$("#lookdoctor-reason").val());
										   //结果
										   param["look.lookinessResult"] = $("#lookdoctor-results").val();
										   console.log(param["look.lookinessResult"] = $("#lookdoctor-results").val());
										},
										success:function(data){
										    $(".window-tishi").text("病人信息已保存,看诊新增成功!");
									    	$("#saveclinic-win").window('open');
									    	//三秒之后自动消失
										   setTimeout(function(){
										    	 $("#saveclinic-win").window('close');
											  }, 3000);
									    	
											//$("#clinic-record-tab").datagrid("reload");
											console.log("看诊data"+data);
											//看诊新增成功将看诊号传回页面-----以便下面处方新增
											//转成json
											var obj = JSON.parse(data);
											$("#lillnessid").val(obj.lookid);
											/* alert(obj.lookid); */
											//看诊完没有叫号依然改
										     var regid=$("#ld_registrid").val();
							                   $.ajax({
							                	     url:'update-callstate?regid='+regid,
							                	     type:'post',
							                	     success:function(data){
							                	    	 console.log("看诊叫号---成功");
							                	    	 $("#call-number-tab").datagrid("reload");
							                	     }
							                   });
										}
									}).submit();
									
								}else{
									console.log("即将进行二次看诊");
									
									//查询到了看诊id---修改
									var lookid =  data[0]["lookillness_id"]
									//医嘱内容
									 var docadvice_conent=$("#lookdoctor-advicecomment").textbox("getValue");
									//诊断结果
									 var lookiness_result=$("#lookdoctor-results").textbox("getValue");
									//病因
									 var lookiness_reason=$("#lookdoctor-reason").textbox("getValue");
									//看诊id
									$("#lillnessid").val(data[0]["lookillness_id"]);
								    //将看诊号对应医嘱主表id存储下来
								    var docadvice_id=data[0]["docadvice_id"];
									console.log("医嘱id------------:"+docadvice_id);
									//将医嘱主键id存着
									$("#docadvices_id").val(docadvice_id);
									//修改医嘱与看诊---ajax
							        $.ajax({
				                	     url:'update-lookillness',
				                	     type:'post',
				                	     data:{
				                	    	 "lookid":lookid,
				                	    	 "docadvice_id":docadvice_id,
				                	    	 "docadviceConent":docadvice_conent,
				                	    	 "lookinessResult":lookiness_result,
				                	    	 "lookinessReason":lookiness_reason
				                	     },
				                	     success:function(data){
				                	    	 $(".window-tishi").text("看诊信息保存成功！！！");
										    	$("#saveclinic-win").window('open');
										    	//三秒之后自动消失
											   setTimeout(function(){
											    	 $("#saveclinic-win").window('close');
											    	 $("#call-number-tab").datagrid("reload");
												  }, 3000);
											   //$("#clinic-record-tab").datagrid("reload");
				                	     }
				                    });
								}
						   }
				  	});
				}else{
					$.messager.confirm('Confirm', 
							'请点击医疗卡框的搜索按钮,选择病人', 
							function(r){
					});
				} 
/* 				$('#lookilness-from').form({    
				    url:'add-lookillness',    
				    onSubmit: function(){    
				        // 执行验证    
				        var c=$('#form-mregistr').form("validate");
				        return c;
				    }, 
				    //表单提交成功之后的数据
				    success:function(data){ 
				    	alert("成功！！");
				   	    /* $('#registration-tab').datagrid('reload');
				   	    $("#lookdoctor-sickuserlbox-sreachbox").textbox('setValue',''); 
				   	    $("#lookdoctor-sickuname").textbox('setValue',''); 
				   	    $("#lookdoctor-sickusex").combobox('reload');
				   	    $("#ld_clinicid").textbox('setValue',''); 
				   	    $("#ld_registrid").textbox('setValue','');
				   	    $("#lookdoctor-sickusercard").textbox('setValue','');
	                    $("#lookdoctor-sickuserTel").textbox('setValue','');
	                    //科室
	                    $("#lookdoctor-sicksection").textbox('setValue','');
	                    $("#lookdoctor-sectionid").textbox('setValue','');
	                    $("# lookdoctor-sickdoctor").textbox('setValue','');
	                    $("# lookdoctor-types").combobox('reload');
	                    $("#lookdoctor-advicecomment").textbox('setValue','');
	                    $("#lookdoctor-results").textbox('setValue','');
	                    $("#  lookdoctor-reason").textbox('setValue',''); 
				    }    
				}).submit();   */
				
			});
		    
        	 //药物追加的按钮
			$("#drug-addsubmits").click(function(){
				var lookdoctor_sreachbox=$("#lookdoctor-sickuserlbox-sreachbox").textbox("getValue");
				if(lookdoctor_sreachbox!=""){
					//获取表格中的信息
					var rows =$("#drug-tab").datagrid('getSelections');
					var copyRows = [];
		            for (var j= 0; j < rows.length; j++) {
		                copyRows.push(rows[j]); //将数据添加到copyRows数组中     
		            }
		            for(var i =0;i<copyRows.length;i++){ 
						var falg = true;
						var index = $('#drug-tab').datagrid('getRowIndex',copyRows[i]);
						//获取追加的表格的行
						var recordrows = $("#docdrug-tab").datagrid("getRows");
						for(var m=0;m<recordrows.length;m++){
						     //判断该datagrid在将要添加的数据中是否存在
						     if(copyRows[i].drug_number == recordrows[m].drug_number){					      
						        	falg = false;
						     }
						} 
		                 if(falg){
		                	 $("#docdrug-tab").datagrid('appendRow',{
		                		 drug_number:rows[i].drug_number,
		                		 category_name:rows[i].category_name,
		                		 type_name:rows[i].type_name,
		                		 drug_name:rows[i].drug_name,
		                		 drug_retail_price:rows[i].drug_retail_price,
		                		 drug_standard:rows[i].drug_standard,
		                		 drug_unit:rows[i].drug_unit
			 		         });
		                 }
		            }
		            //清除所有所选的项
			        $("#drug-tab").datagrid('clearChecked');	
				}else{
					$.messager.confirm('Confirm', 
							'请选择完病人,再选择药品', 
							function(r){
					});
				}
		
			});
        	   
        	// 药物追加完成的表格
	    	 $('#docdrug-tab').datagrid({
	 			    url:'',
	 			    pagination:true,
	 			    pageNumber:1,
	 			    pageSize:3,
	 			    pageList:[2,3],
	 			    columns:[[
	 			    	 	{field:'drug_number',title:'药品编号',width:120,checkbox:true,hidden:true},
	 			    	 	{field:'category_name',title:'药品类别',width:90},
	 			    		{field:'type_name',title:'药品类型',width:103},
	 						{field:'drug_name',title:'药品名称',width:135},
	 						{field:'drug_retail_price',title:'药品单价',width:80},
	 						{field:'drug_standard',title:'药品规格',width:120},
	 						{field:'drug_unit',title:'单位',width:80},
	 						{field:'drug_nu',title:'数量',width:52,align:'center',
	 							formatter:function(value,row,index){
									 //输入框
									  var stryongliang="<input  class='drugamount ' min='1' type='number' style='width:40px;' value='1'/>"
									 return stryongliang;
								}	
	 						},
	 						{field:'drug_pingdu',title:'用药频度',width:116,align:'center',
	 							formatter:function(value,row,index){
									 //输入框
									 var drug_pingdu="<input  class='drug_pingdu easyui-textbox' style='width:105px' value=''/>"
									 return drug_pingdu;
								}	
	 						},
	 						{field:'drug_useliang',title:'药物用量',width:116,align:'center',
	 							formatter:function(value,row,index){
									 //输入框
									  var drug_useliang="<input  class='drug_useliang easyui-textbox' style='width:105px' value=''/>"
									 return drug_useliang;
								}	
	 						},
	 						{field:'drug_remove',title:'操作',width:75,align:'center',
	 							formatter:function(value,row,index){
	 								 return  "<a onclick='drug_remove("+row.drug_number+")'>移除</a>"
									
								}	
	 						}
	 			    ]]
	 			});
        	
        //开立医嘱---非空判断
        //获取表格中的药品信息
		var rows_drug = $("#docdrug-tab").datagrid("getRows");
		//开立医嘱的确定按钮(医嘱表，医嘱详情表)-----药物新增
		$("#docdrug-addsubmits").click(function(){
        	if(rows_drug.length>0){
     				var docid=$("#docadvices_id").val();
     				console.log(docid+"---------------"+docid.length);
     				if(docid.length==0){
     	        	/* 	alert("医嘱id为空---直接新增！！！！！"); */
    		    			$("<form method='post' id='for'>").appendTo("body").form({
    		    				url:'add-docdrug',
    		    				onSubmit:function(param){
    		    					 //看诊id
    		    				    param["look.lookillnessId"] = $("#lillnessid").val();			
    		    				    console.log( "开药看诊id----------");
    		    				    console.log(param["look.lookillnessId"]);
    		    				    console.log( "开药看诊id----------");
    		    				  
    		    					//获取医嘱内容
    		    					param["advice.docadviceConent"] = $("#lookdoctor-advicecomment").val();	
    		    					console.log(param["advice.docadviceConent"] = $("#lookdoctor-advicecomment").val());
    		    					//获取医嘱类型----门诊处方0
    		    					param["advice.doctorType"] = 0;
    		    					
    		    					//收费状态
    		    				   param["advice.docMoneytype"] = 0;
    		    					
    		    					//获取表格中的药品信息
    		    					var rows = $("#docdrug-tab").datagrid("getRows");
    		    					console.log(rows);
    		    					var total=0;
    		    					for (var i = 0; i < rows.length; i++) {
    		    						//药品编号
    		    					    //console.log("药品编号-------------");
    		    						param["details["+i+"].drug.drugNumber"] = rows[i]["drug_number"];
    		    						//console.log(param["details["+i+"].drug.drugNumber"] = rows[i]["drug_number"]);
    		    						//药品的单个数量
    		    					    param["details["+i+"].docdetailsEverynnum"] =$(".drugamount:eq(' "+i+" ')").val();
    		    					    //console.log("药品单个数量-------------");
    		    						//console.log( param["details["+i+"].docdetailsEverynnum"] =$(".drugamount:eq(' "+i+" ')").val());
    		    					    //console.log("药品单个数量-end------------");
    		    						//药品的总数量
    		    						total +=parseInt( $(".drugamount:eq(' "+i+" ')").val());
    		    						
    		    					   //医嘱详情单个药品用药频度 
    				    			   param["details["+i+"].docdetailsDrugpingdu"] =$(".drug_pingdu:eq(' "+i+" ')").val();
    			    				   //console.log("药品用药频度-------------:"+ param["details.docdetailsDrugpingdu"] );
    			    				   //医嘱详情单个药品用药多少
    			    				   param["details["+i+"].docdetailsDruguseliang"] = $(".drug_useliang:eq(' "+i+" ')").val();
    		    					   var ss=$(".drug_useliang:eq(' "+i+" ')").val();
    		    					   var ff=$(".drug_useliang:eq(' "+i+" ')").val();
    			    				  if(ss=="" || ff==""){
    			    					  $.messager.confirm('Confirm', 
    			    								'请药品的用量或者频度,它们不能为空', 
    			    								function(r){
    			    					  });
    			    					  return false;
    			    				  }
    		    					}
    		    					
    		    				  param["advice.docDrugallnumber"] =parseInt( total); 
    		    				  console.log("药品ddd总数-----------:"+parseInt( total));
    		    				  
    		    				  //医嘱详情---单个药品收费状态----0未收费 ---------1收费
    		    				  param["details.docdetailsType"] =0;
    		    				  
    		    				},
    		    				success:function(data){
    		    					 $(".window-tishi").text("医嘱开立药物添加成功!!!");
    							    	$("#saveclinic-win").window('open');
    							    	//三秒之后自动消失
    								   setTimeout(function(){
    								    	 $("#saveclinic-win").window('close');
    									  }, 3000);
    							    	
    		    					 $('#for').form("clear");//清空文本
    		    					//清空选中的药品
    		    					$("#drug-tab").datagrid('clearChecked');
    		    					$("#docdrug-tab").datagrid("loadData", {total:0, rows:[]});
    		    				}
    		    			}).submit();
     		}
     	    //查到医嘱id
     		if(docid.length>0){
     			//alert("医嘱id不为空！！！！------："+docid);	
     			/* 医嘱id不为空说明已经开了一次药 
     			再开药就是在原来医嘱主键之下新增医嘱详情
     			*/
     			//新增医嘱详情
     			$("<form method='post' id='for'>").appendTo("body").form({
     				url:'save-Docterredo',
     				onSubmit:function(param){
     					//收费状态
     				   param["advice.docMoneytype"] = 0;
     					//医嘱主表id
     					param["advice.docadviceId"] =$("#docadvices_id").val();
     					//alert("有医嘱----医嘱主表id："+param["doctorsAdvice.docadviceId"]);
     					//获取表格中的药品信息
     					var rows = $("#docdrug-tab").datagrid("getRows");
     					console.log(rows);
     					var total=0;
     					for (var i = 0; i < rows.length; i++) {
     						//药品编号
     					    console.log("药品编号345-------------");
     						param["details["+i+"].drug.drugNumber"] = rows[i]["drug_number"];
     						console.log(param["details["+i+"].drug.drugNumber"] = rows[i]["drug_number"]);
     						//药品的单个数量
     					   param["details["+i+"].docdetailsEverynnum"] =$(".drugamount:eq(' "+i+" ')").val();
     					    console.log("药品单个数量-------------");
     						console.log( param["details["+i+"].docdetailsEverynnum"] =$(".drugamount:eq(' "+i+" ')").val());
     					    console.log("药品单个数量-end------------");
     						//药品的总数量
     						total +=parseInt( $(".drugamount:eq(' "+i+" ')").val());
     						
     						//医嘱详情单个药品用药频度 
    		    			   param["details["+i+"].docdetailsDrugpingdu"] =$(".drug_pingdu:eq(' "+i+" ')").val();
    	    				   console.log("药品用药频度-------------:"+ param["details.docdetailsDrugpingdu"] );
    	    				   //医嘱详情单个药品用药多少
    	    				   param["details["+i+"].docdetailsDruguseliang"] = $(".drug_useliang:eq(' "+i+" ')").val();
     					}
     				  param["advice.docDrugallnumber"] =parseInt( total); 
     				  console.log("药品ddd总数-----------:"+parseInt( total));
     				  
     				  //医嘱详情---单个药品收费状态----0未收费 ---------1收费
     				  param["details.docdetailsType"] =0;
     				},
     				success:function(data){
     					 $(".window-tishi").text("药物添加成功！！！");
    					    	$("#saveclinic-win").window('open');
    					    	//三秒之后自动消失
    						   setTimeout(function(){
    						    	 $("#saveclinic-win").window('close');
    							  }, 3000);
     					$('#for').form("clear");//清空文本
     					//清空选中的药品
     					$("#drug-tab").datagrid('clearChecked');
     					$("#docdrug-tab").datagrid("loadData", {total:0, rows:[]});
     				}
     			}).submit();
     			
     			
     		}
        	}else{
        		//alert('请选择完药品,再点击确定按钮');
        		$.messager.confirm('Confirm', 
						'请选择完药品,再点击确定按钮', 
						function(r){
				});
        	}
       });  	 
	
	    	 
 	    //医疗项目追加
    	$("#hospitalproject-addsubmit").click(function(){
		//获取表格中的信息
		var rows =$("#hospitalproject-tab").datagrid('getSelections');
		var copyRows = [];
           for (var j= 0; j < rows.length; j++) {
               copyRows.push(rows[j]); //将数据添加到copyRows数组中     
           }
           for(var i =0;i<copyRows.length;i++){ 
			var falg = true;
			var index = $('#hospitalproject-tab').datagrid('getRowIndex',copyRows[i]);
			//获取追加的表格的行
			var recordrows = $("#dochospitalproject-tab").datagrid("getRows");
			for(var m=0;m<recordrows.length;m++){
			     //判断该datagrid在将要添加的数据中是否存在
			     if(copyRows[i].hospital_project_id == recordrows[m].hospital_project_id){					      
			        	falg = false;
			     }
			} 
                if(falg){
               	 $("#dochospitalproject-tab").datagrid('appendRow',{
               		 hospital_project_id:rows[i].hospital_project_id,
               		 hospital_project_name:rows[i].hospital_project_name,
               		 hospital_project_price:rows[i].hospital_project_price
 		         });
                }
           }
           //清除所有所选的项
        $("#hospitalproject-tab").datagrid('clearChecked');	
	});
 	    
	    	 
      //医疗项目添加表格
   	  $('#dochospitalproject-tab').datagrid({
   		    url:'',
   		    pagination:true,
   		    pageNumber:1,
   		    pageSize:3,
   		    pageList:[3,6],
   		    columns:[[
   		    	    {field:'hospital_project_id',title:'',width:40,checkbox:true,hidden:true},
   		    	 	{field:'hospital_project_name',title:'项目名称',width:450},
   					{field:'hospital_project_price',title:'项目价格',width:430},
   				    {field:'hospital_project_remove',title:'操作',width:88,align:'center',
						formatter:function(value,row,index){
							 return  "<a onclick='hospital_project_remove("+row.hospital_project_id+")'>移除</a>"
							
						}	
				   }
   		    ]]
   		});
		
		
			//开医疗项目
			$("#dochospitalproject-addsubmit").click(function(){
			$("<form method='post' id='hosproject'>").appendTo("body").form({
				url:'save-Hosproject',
				onSubmit:function(param){
					 //看诊id
				    param["lookillness.lookillnessId"] = $("#lillnessid").val();						
				    console.log( "开医疗项目看诊id----------");
				    console.log(param["lookIllness.lookillnessId"]);
				    console.log( "开医疗项目看诊id----------");
					//医疗项目缴费状态---未交费
				   param["lookhosproject.hospLookState"] =1;

					//获取表格中的医疗项目信息
					var rows = $("#dochospitalproject-tab").datagrid("getRows");
					console.log(rows);
					for (var i = 0; i < rows.length; i++) {
						//医疗项目编号
					    console.log("医疗项目编号-------------");
						param["lookhosprojectdetails["+i+"].hospitalProject.hospitalProjectId"] = rows[i]["hospital_project_id"];
						console.log(param["lookhosprojectdetails["+i+"].hospitalProject.hospitalProjectId"] = rows[i]["hospital_project_id"]);
					}
				
				},
				success:function(data){
					    $(".window-tishi").text("医疗项目开立成功！！！");
				    	$("#saveclinic-win").window('open');
				    	//三秒之后自动消失
					   setTimeout(function(){
					    	 $("#saveclinic-win").window('close');
						  }, 3000);
					$("#hospitalproject-tab").datagrid('clearChecked');
					 $("#dochospitalproject-tab").datagrid("loadData", {total:0, rows:[]});
				}
			}).submit();
			
	    });
		
		//叫号窗口
		$(".lookdoctor-callnumber").click(function(){
			//alert("叫号窗口！！！");
			var rowd=	$("#call-number-tab").datagrid("getRows");
		    	//打开窗口
				$("#call-number-win	").window('open');
		   });
		       //叫号窗口初始化
				$("#call-number-tab").datagrid({
			   		 url:'lookdoctor-callNumber',
			   		 pagination:true,
    	      		 pageNumber:1,
    	      		 pageSize:7,
    	      		 pageList:[7,8],
			   		 columns:[[
						    {field:'clinic_id',title:'医疗卡编号',hidden:true},
				    	 	{field:'cliniccard_id',title:'医疗卡号',width:126},
				    	 	{field:'registr_id',title:'挂号id',hidden:true},
				    		{field:'clinic_name',title:'病人姓名',width:90},
							{field:'clinic_sex',title:'性别',width:60},
							{field:'clinic_idnumber',title:'身份证号',width:150},
							{field:'clinic_tel',title:'电话',width:120},
							{field:'section_id',title:'科室编号',hidden:true},
							{field:'section_name',title:'科室',width:100},
							{field:'uid',title:'医生编号',hidden:true},
							{field:'registr_docname',title:'挂号医生',width:100}
			       ]]
			    });
		
				//叫号双击表格事件
				$("#call-number-tab").datagrid({
				onDblClickRow: function(rowIndex,rowData){
					     //登录人id
					     var loginuserid=$("#userId").val();
					     //登录人名字
					     var loginusername=$("#userName").val();
					    //分诊医生id
					     var triageuserid=rowData["uid"] 
					     console.log("登录人id:"+loginuserid+"---------登录人名字:"+loginusername+"---------分诊医生id:"+triageuserid);
					     //如果登录人id！=接诊医生id-->看诊获取的医生名字就是登录人
					     if(loginuserid!=triageuserid){
					    	 console.log("登录人id!=接诊医生id----------进入");
					    	     //登录人为医生
	  		                    $("#lookdoctor-sickdoctor").textbox('setValue',loginusername);
	  		                    //登录用户id
	  		                    $("#userid").val(loginuserid);
	  		                    
	  					        //医疗卡
	  		                    $("#lookdoctor-sickuserlbox-sreachbox").textbox('setValue',rowData['cliniccard_id']); 
	  		                    $("#lookdoctor-sickuserlbox-sreachbox").textbox("readonly","true");
						  	 	//医疗卡主键
	  		                     $("#ld_clinicid").val(rowData['clinic_id']); 
	  		                    //挂号id
	  		                     $("#ld_registrid").val(rowData['registr_id']); 
	  		                    //患者姓名
	  		                     $("#lookdoctor-sickuname").textbox('setValue',rowData['clinic_name']); 
	  		                    //患者性别
	  		                    $("#lookdoctor-sickusex").combobox('setValue',rowData['clinic_sex']);
	  		                    //身份证号
	  		                    $("#lookdoctor-sickusercard").textbox('setValue',rowData['clinic_idnumber']);
	  		                    //手机号码
	  		                    $("#lookdoctor-sickuserTel").textbox('setValue',rowData['clinic_tel']);
	  		                    //科室
	  		                    $("#lookdoctor-sicksection").textbox('setValue',rowData['section_name']);
	  		                    $("#lookdoctor-sectionid").textbox('setValue',rowData['section_id']);
					     }
					   
					     if(loginuserid==triageuserid){
					    	     console.log("分诊医生本人进入！！！！");
					    	    //医疗卡
	  		                    $("#lookdoctor-sickuserlbox-sreachbox").textbox('setValue',rowData['cliniccard_id']); 
	  		                    $("#lookdoctor-sickuserlbox-sreachbox").textbox("readonly","true");
						  	 	//医疗卡主键
	  		                     $("#ld_clinicid").val(rowData['clinic_id']); 
	  		                    //挂号id
	  		                     $("#ld_registrid").val(rowData['registr_id']); 
	  		                    //患者姓名
	  		                     $("#lookdoctor-sickuname").textbox('setValue',rowData['clinic_name']); 
	  		                    //患者性别
	  		                    $("#lookdoctor-sickusex").combobox('setValue',rowData['clinic_sex']);
	  		                    //身份证号
	  		                    $("#lookdoctor-sickusercard").textbox('setValue',rowData['clinic_idnumber']);
	  		                    //手机号码
	  		                    $("#lookdoctor-sickuserTel").textbox('setValue',rowData['clinic_tel']);
	  		                    //科室
	  		                    $("#lookdoctor-sicksection").textbox('setValue',rowData['section_name']);
	  		                    $("#lookdoctor-sectionid").textbox('setValue',rowData['section_id']);
	  		                	//医生
	  		                    $("#lookdoctor-sickdoctor").textbox('setValue',rowData['registr_docname']);
	  		                    //用户id
	  		                    $("#userid").val(rowData["uid"]);
					     }
			                   //关闭窗口
			                  $("#call-number-win").window("close");
			                   var regid=rowData['registr_id'];
			                  
			                   $.ajax({
			                	     url:'update-callstate?regid='+regid,
			                	     type:'post',
			                	     success:function(data){
			                	    	 //alert("成功");
			                	     }
			                   });
			                   
					 }
				
		   		});
		
 }) ; //$(function(){  })  
         
         //药物移除表格一行
         function drug_remove(drugnumber){
        	 var row = $('#docdrug-tab').datagrid('getSelected');
        	 if (row) {
                 var rowIndex = $('#docdrug-tab').datagrid('getRowIndex', row);
                 $('#docdrug-tab').datagrid('deleteRow', rowIndex);
             }
         }
         
         //体检项目移除表格一行
         function project_remove(project_no){
        	 var row = $('#doclookchekuphealth-tabs').datagrid('getSelected');
        	 if (row) {
                 var rowIndex = $('#doclookchekuphealth-tabs').datagrid('getRowIndex', row);
                 $('#doclookchekuphealth-tabs').datagrid('deleteRow', rowIndex);
             }
         }
         
         //医疗项目移除表格一行
         function hospital_project_remove(hospital_project_id){
        	 var row = $('#dochospitalproject-tab').datagrid('getSelected');
        	 if (row) {
                 var rowIndex = $('#dochospitalproject-tab').datagrid('getRowIndex', row);
                 $('#dochospitalproject-tab').datagrid('deleteRow', rowIndex);
             }
         }
         
       //日期格式化
 		function comFormatDate(date) {
 			var day = new Date(date); 
 			var Year = 0; 
 			var Month = 0; 
 			var Day = 0; 
 			var CurrentDate = ""; 
 			//初始化时间 
 			Year= day.getFullYear();//ie火狐下都可以 
 			Month= day.getMonth()+1; 
 			Day = day.getDate(); 
 			Hour = day.getHours(); 
 			 Minute = day.getMinutes(); 
 			 Second = day.getSeconds(); 
 			CurrentDate += Year + "-"; 
 			if (Month >= 10 ) { 
 				CurrentDate += Month + "-"; 
 			}else { 
 				CurrentDate += "0" + Month + "-"; 
 			} 
 			if (Day >= 10 ) { 
 				CurrentDate += Day ; 
 			}else { 
 				CurrentDate += "0" + Day ; 
 			} 
 			if(Hour>=10){
 				CurrentDate +=" "+Hour;
 			}else{
 				CurrentDate +=" "+"0"+Hour;
 			}
 			if(Minute>=10){
 				CurrentDate +=":"+Minute;
 			}else{
 				CurrentDate +=":"+"0"+Minute;
 			}
 			if(Second>=10){
 				CurrentDate +=":"+Second;
 			}else{
 				CurrentDate +=":"+"0"+Second;
 			}
 			return CurrentDate; 
 		}
    
</script>
<!-- <div id="lookdoctorMaxpanle" class="easyui-tabs" > -->
			<div class="lookdoctor-maxbox easyui-panel"  data-options="fit:true" style="border:1px solid #F3F3F4;">
			    <div class="lookdoctor-topbox">
			        <a class="apply-insicker">住院申请</a>
			        <a class="lookdoctor-book">病历本</a>
			        <a class="lookdoctor-callnumber">叫号</a>
			    </div><!-- lookdoctor-topbox -->
			    
			    <div class="lookdoctor-sickuserlbox">
			        <fieldset style="border:1px solid #A6A6A6;border-radius:6px;width:1050px;margin:0 auto;margin-top:10px;margin-bottom:20px;">
			             <legend style="font-size:17px">基本信息</legend>
			             <form id="lookilness-from" method="post">
			             <div class="lookdoctor-sickuserlbox-one">
			               <a style="margin-left: 10px;">
			                  <span style="margin-right:7px;"> 医疗卡号</span>
			                   <input id="lookdoctor-sickuserlbox-sreachbox" class="easyui-searchbox" style="width:130px" data-options="width:130,height:30,required:true"/>
			                   <input name="clinic_id"   type="hidden"  id="ld_clinicid" >
			                   <input name="registrfrom_id"    type="hidden"   id="ld_registrid">
			                   <input name="look_state"  type="hidden"  id="look_state" value="1">
			                   <input name="userid"   id="userid"  type="hidden" >
			              </a>
			                   <a style="margin-left:58px;">
			                   	<span style="margin-right:7px;">患者姓名</span>
								<input id="lookdoctor-sickuname" name="lookdoctor-sickuname" class="easyui-textbox"  data-options="width:130,height:30,required:true,readonly:true">
			                 </a>
			                 
			                 <a style="margin-left:50px;">
								<span style="margin-right:7px;">性别</span>
								<span class="lookdoctor-lusexbox">
								<select id="lookdoctor-sickusex" class="easyui-combobox" data-options=" panelHeight:'auto',readonly:true" style="width:100px; height: 30px;line-height: 30px;">
								   <option>男</option>
								   <option>女</option>
								</select>
								</span>
							</a>
							
							<a style="margin-left:75px;">
							      <span style="margin-right:7px;"> 身份证号</span>
			                      <input id="lookdoctor-sickusercard" class="easyui-textbox"  data-options="width:135,height:30,required:true,readonly:true"></input>
							</a>
			             </div>
			             
			             <div class="lookdoctor-sickuserlbox-two">
			               <a >
			                	<span style="margin-right:7px;">联系电话</span>
			                    <input id="lookdoctor-sickuserTel" class="easyui-textbox"  data-options="width:130,height:30,required:true,readonly:true">
			              </a>
			              
			               <a style="margin-left:60px;">
								 <span style="margin-right:33px;">科室</span>
							      <input id="lookdoctor-sicksection" class="easyui-textbox"  data-options="width:130,height:30,required:true,readonly:true">	
						   </a>
							 <input id="lookdoctor-sectionid" class="easyui-textbox" type="hidden">	
							<a style="margin-left:44px;">
			                  	<span style="margin-right:7px;">医生</span>
							      <input id="lookdoctor-sickdoctor" class="easyui-textbox"  data-options="width:100,height:30,required:true,readonly:true">
			                 </a> 
			                 
			                 <a  style="margin-left:75px;">
			                     <span style="margin-right:7px;">就诊类型</span>
						         <select id="lookdoctor-types" class="lookdoctor-types"  style="width: 135px;height:30px;line-height:30px;border-radius: 5px;">
									   <option>初诊</option>
									   <option>复诊</option>
						   		 </select>
			                 </a>
			             </div>
			             
			              <div class="lookdoctor-sickuserlbox-three">
						               <a style="margin-left: 7px;">
						                   	<span style="margin-right:7px;">诊断结果</span>
											<input id="lookdoctor-results" name="lookdoctor_results" class="easyui-textbox"  data-options="width:130,height:30,required:true">
									   </a>
						           
						              <a  style="margin-left:60px;">
						                   	<span style="margin-right:33px;">病因</span>
											<input id="lookdoctor-reason" name="lookdoctor_reason" class="easyui-textbox"  data-options="width:130,height:30,required:true">
						              </a>
						              
			             </div>
			             <p style="width:200px;margin:0 auto;margin-left: 87.5%;;display:inline-block;">
			            		 <a id="save-lookilness" class="a easyui-linkbutton"   data-options="iconCls:'icon-ok',border:false">保存</a> 
     		             </p>
                     </form>
			         </fieldset>    
			        
			         <!-- 处方管理 -->
					  <fieldset style="border:1px solid #A6A6A6;border-radius:6px;width:1050px;overflow: hidden;margin:0 auto;margin-top:20px;margin-bottom:20px;">
					             <legend style="font-size:17px">医嘱管理</legend>
					              <!--   存看诊id -->
			       				  <input  type="hidden"  id="lillnessid"  name="lookillnessId" >
			       				 <!--  医嘱主表id -->
			       			     <input  type="hidden"  id="docadvices_id"  name="docadvice_id" > 
			       			     <!--  医嘱内容-->
			       			         <a style="margin-left:39px;">
						                  <span style="margin-right:15px;"> 医嘱内容</span><!-- value=" 多喝水，少吃辛辣" -->
						                   <input id="lookdoctor-advicecomment" class="easyui-textbox" data-options="width:210,height:30,required:true" >
						              </a>
			             			<div id="doctordetails" class="easyui-tabs"  style="width:1047px;overflow:hidden;margin-top:10px;border: 1px solid #bbb;">
										 <div title="药物选择" style="padding:20px;display:none;overflow: hidden;">
										       <a style="margin-left:14px;">
										          	<input id="search-checkdrugname" name="search-checkdrugname" class="easyui-searchbox"  data-options="width:150,height:30,prompt:'请输入药物名称'">
										        </a>
										        
<!-- 										       <a style="margin-left:14px;display:inline-block;" class=" easyui-linkbutton">注意事项</a> 
 -->										       
										     <div style="margin-left:15px;margin-top:20px;">
											     	 <table id="drug-tab" class="easyui-datagrid" data-options="fitColumns:false,checkOnSelect:false,width:970" >
												  
												    </table>
												     <p style="width:100px;margin:0 auto;margin-left: 89%;display:inline-block;margin-top: 15px;">
		            		             			 <a  id="drug-addsubmits" class="easyui-linkbutton"   data-options="iconCls:'icon-ok',border:false">添加至药单</a> 
		                          					</p>
												    <!-- 药物选择完之后的盒子 -->
												    <div style="margin-top:15px;">
												        <table id="docdrug-tab" class="easyui-datagrid" data-options="fitColumns:false,singleSelect:true,width:970,height:135" >
												  
												       </table>
												        <p style="width:100px;margin:0 auto;margin-left:92%;display:inline-block;margin-top: 15px;">
		            		             			    	 <a  id="docdrug-addsubmits" class="easyui-linkbutton"   data-options="iconCls:'icon-ok',border:false">确定</a> 
		                          					   </p>
												    </div>
											</div>	<!-- tab盒子 -->
									       
										 </div><!-- 药品选择 -->
										 
										 <div title="体检项目" style="padding:20px;display:none;overflow: hidden;">
										     <a style="margin-left:17px;">
										          	<input id="search-checkhospname" name="search-checkpname" class="easyui-searchbox"  data-options="width:150,height:30,prompt:'请输入体检项目名称'">
										        </a>
											   <div style="margin-left:17px;margin-top:20px;">  
										     	  <table id="lookchekuphealth-tabs" class="easyui-datagrid" data-options="fitColumns:false,singleSelect:false,width:970,height:135" >

											    </table>
											  </div>	<!-- tab盒子 -->
											   <p style="width:100px;margin:0 auto;margin-left:93%;display:inline-block;margin-top: 15px;">
			            		             		 <a  id="lookcheckhealth-addsubmit" class="easyui-linkbutton"   data-options="iconCls:'icon-ok',border:false">添加</a> 
			                          			</p>
			                          			
			                          			<!-- 体检项目单子 -->
			                          			  <div style="margin-left:17px;margin-top:20px;">  
										     	  <table id="doclookchekuphealth-tabs" class="easyui-datagrid" data-options="fitColumns:false,singleSelect:false,width:970,height:135" >

											    </table>
											  </div>	<!-- tab盒子 -->
											   <p style="width:100px;margin:0 auto;margin-left: 93%;display:inline-block;margin-top: 15px;">
			            		             		 <a  id="doclookcheckhealth-addsubmit" class="easyui-linkbutton"   data-options="iconCls:'icon-ok',border:false">确认</a> 
			                          			</p>
			                          			 
										    </div><!-- 体检项目 -->
										    
										     <div title="医疗项目" style="padding:20px;display:none;overflow: hidden;">
										       <a style="margin-left:17px;">
										          	<input id="search-checkyilname" name="search-checkyilname" class="easyui-searchbox"  data-options="width:150,height:30,prompt:'请输入医疗项目名称'">
										         </a>
											   <div style="margin-left:17px;margin-top:20px;"> 
										     	  <table id="hospitalproject-tab" class="easyui-datagrid" data-options="fitColumns:false,singleSelect:false,width:970,height:135" >
											 	</table>
											  </div>	<!-- tab盒子 -->
											   <p style="width:100px;margin:0 auto;margin-left:93%;display:inline-block;margin-top: 15px;">
			            		             			 <a  id="hospitalproject-addsubmit" class="a easyui-linkbutton"   data-options="iconCls:'icon-ok',border:false">添加</a> 
			                          			</p>
			                          		<!-- 	医疗项目单子 -->
			                          		  <div style="margin-left:17px;margin-top:20px;"> 
										     	  <table id="dochospitalproject-tab" class="easyui-datagrid" data-options="fitColumns:false,singleSelect:false,width:970,height:135" >
											   	  </table>
											   </div>	<!-- tab盒子 -->
											   <p style="width:100px;margin:0 auto;margin-left: 93%;display:inline-block;margin-top: 15px;">
			            		             			 <a  id="dochospitalproject-addsubmit" class="a easyui-linkbutton"   data-options="iconCls:'icon-ok',border:false">确定</a> 
			                          		  </p>
			                          			
										    </div><!-- 医疗项目 -->
								</div>
					  </fieldset>
			         
			    </div><!-- lookdoctor-sickuserlbox -->

			</div><!-- lookdoctor-maxbox -->
			<!--住院申请 -->
			<div id="quick-lookdoctor-win" class="easyui-window" title="住院申请" style="width:800px;height:500px"
			    data-options="iconCls:'icon-save',modal:true,resizable:false,collapsible:false,maximizable:false,minimizable:false,closed:true">
						<form id="quick-lookdoctor" method="post">
							<!-- 第一行盒子 -->
							<div class="quick-onebox" style="width:730px;margin:0 auto;margin-bottom:30px;margin-top:60px;font-size:18px;">
							  	<a style=" margin-left:60px;">
							  			<span style="margin-right:7px;">看诊编号</span>
										<input id="quick-uclickcard" name="quicklookid" class="easyui-searchbox"  data-options="width:150,required:true">
								</a>
								
								<a style="margin-left:130px;">
								       <span style="margin-right:7px;">患者姓名</span>
										<input id="quick-unames" name="quick-uname" class="easyui-textbox"  data-options="width:150,height:30,required:true">
								</a>
								
							</div>
							<!-- 第二行盒子 -->
							<div class="quick-twobox" style="width:730px;margin:0 auto;margin-bottom:30px;margin-top:20px;font-size:18px;">
							   	<a style="margin-left:60px;">
							   	        <span style="margin-right:7px;">病人性别</span>
										<span class="quick-usexbox">
										<select id="quick-usex"  class="easyui-combobox" data-options=" panelHeight:'auto'" style="width:150px; height: 30px;line-height: 30px;">
										   <option>男</option>
										   <option>女</option>
										</select>
										</span>
							   </a>
							   
							   <a style="margin-left:130px;">
							   			<span style="margin-right:7px;">身份证号</span>
									   	<input id="quick-ucard" name="quick-ucard" class="easyui-textbox" data-options="width:150,height:30,required:true">
							</a>
							</div>
							
								<!-- 第三行盒子 -->
							<div class="quick-threebox" style="width:730px;margin:0 auto;margin-bottom:30px;margin-top:20px;font-size:18px;">
							   	<a style="margin-left:60px;">
							   	         <span style="margin-right:7px;">病人病因</span>
									   	<input id="quick-ureason" name="quick-ureason" class="easyui-textbox" data-options="width:150,height:30,required:true">
							   </a>
							   
							    <a style="margin-left:130px;">
							    	<span style="margin-right:7px;">手机号码</span>
									<input id="quick-utel" name="quick-utel" class="easyui-textbox" data-options="width:150,height:30,required:true">
							    </a>
							</div>
							
							<!-- 第四行 -->
					      <div class="quick-fourbox" style="width:730px;margin:0 auto;margin-bottom:45px;margin-top:20px;font-size:18px;">
							 <a style="margin-left:60px;">
							     <span style="margin-right:7px;">所挂科室</span>
							  	<input id="quick-usection" name="quick-usection" class="easyui-textbox" data-options="width:150,height:30,required:true">

							 </a>
					  	  
					  	  <a style="margin-left:130px;">
							  	<span style="margin-right:7px;">门诊医生</span>
							  <input id="quick-udocname" name="quick-udocname" class="easyui-textbox" data-options="width:150,height:30,required:true">

						  </a>
						</div>	
						
						<!-- 第五行 -->
					    <!--   <div class="quick-fIvebox" style="width:730px;margin:0 auto;margin-bottom:45px;margin-top:20px;font-size:18px;">
							 <a style="margin-left:60px;">
							     <span style="margin-right:7px;">接诊类型</span>
							     <select class="quick-lookdoctortype" >
									   <option>初诊</option>
									   <option>复诊</option>
							 	</select>
							 </a>
					  	  
					  	  <a style="margin-left:170px;">
							  	<span style="margin-right:7px;">所在地址</span>
							  	<input id="quick-address" name="quick-address" class="easyui-textbox" data-options="width:150,height:30,required:true">
						  </a>
						</div>	 -->
						    <input type="hidden" value="${user.userName}"  id="applyuser"  name="applyuser">
							<p><a id="submit-quick-lookdoctor" style="margin-left:43%;margin-top:72px;" class="quicks-yesbtn easyui-linkbutton"   data-options="iconCls:'icon-ok',border:false">提交</a><p>
						</form>
			</div>
		      
<!--     </div>
 -->    

      <!-- 看诊网格窗口 -->
	 <div id="clinic-record-win" class="easyui-window" title="病人信息" style="width:770px;height:400px"
	    data-options="iconCls:'icon-save',closed:true,modal:true,shadow:true,resizable:false,collapsible:false,minimizable:false,maximizable:false">
			<table  id="clinic-record-tab" style="height:363px">
			
			</table>
      </div>
      
       <!-- 叫号网格窗口 -->
	 <div id="call-number-win" class="easyui-window" title="叫号窗口" style="width:765px;height:400px"
	    data-options="iconCls:'icon-save',closed:true,modal:true,shadow:true,resizable:false,collapsible:false,minimizable:false,maximizable:false">
			<table  id="call-number-tab" style="height:350px">
			
			</table>
      </div>
      
      <!-- 病例网格 -->
      <div id="lookdoctor-book-win" class="easyui-window" title="病例记录" style="width:785px;height:430px;"
	    data-options="iconCls:'icon-save',closed:true,modal:true,shadow:true,resizable:false,collapsible:false,minimizable:false,maximizable:false">
			<div id="look-patient-tab" style="width:771px;height: 398x;/* border: 1px solid #bbb; */">
			         <!--  左边盒子 -->
			          <div style="width:222px;height:382px;border:1px solid #529fc6;float:left;margin-top:5px;margin-left: 5px;">
			                <a style="width:220px;height:42px;border:1px solid #529fc6;font-size:17px; display: inline-block;
			                 line-height: 42px;text-align: center;background: #529fc6;color: white;">患者基本信息</a>
			               <div style=" padding-left:14px;width:205px;margin-top: 5px;">
			                <div style="margin-top:20px;">  
			                  <span style="margin-right:7px;"> 医疗卡号</span>
			                  <input id="lclinic_cardid" class="easyui-textbox" style="width:130px" data-options="width:130,height:30,required:true,readonly:true"/>
			                </div>  
			                <div style="margin-top:24px;">
			                   	<span style="margin-right:7px;">患者姓名</span>
								<input id="luname" name="luname" class="easyui-textbox"  data-options="width:130,height:30,required:true,readonly:true">
			                 </div>
			                 
			                 <div style="margin-top:24px;">
								<span style="margin-right:7px;">患者性别</span>
								<span >
								<select id="lusex" class="easyui-combobox" data-options=" panelHeight:'auto',readonly:true" style="width:130px; height: 30px;line-height: 30px;">
								   <option>男</option>
								   <option>女</option>
								</select>
								</span>
							</div>
							
							  <div style="margin-top:24px;">
			                   	<span style="margin-right:7px;">身份证号</span>
								<input id="luserID" name="luserID" class="easyui-textbox"  data-options="width:130,height:30,required:true,readonly:true">
			                 </div>
			                 
			                   <div style="margin-top:24px;">
			                   	<span style="margin-right:7px;">联系电话</span>
								<input id="lusertel" name="lusertel" class="easyui-textbox"  data-options="width:130,height:30,required:true,readonly:true">
			                 </div>
			                </div>
			                 <div style="margin-top:24px;margin-left:10px;">
			                   	 <a style="margin-right:1px;" class="look-patient-date-btn easyui-linkbutton" >日期查询</a>
								<input id="look-patient-date" name="look-patient-date" class="easyui-datebox" editable="false"  data-options="width:130,height:30">
			                 </div>
			                </div>
			          </div>
			          <!--  右边盒子 -->
			           <div style="width:521px;height:382px;border:1px solid #529fc6;float:left;margin-left:5px;margin-top:5px;">
			                     <a style="width:519px;height:42px;border:1px solid #529fc6;font-size:17px; display: inline-block;
			                        line-height: 42px;text-align: center;background: #529fc6;color: white;">患者病例</a>
			                     <div  class="ttabs easyui-tabs"  style="width:522px;height:338px;">
			                        <div title="看诊记录">
			                            <table  id="look-patientsRecord-tab" style="width:520px;height:303px;margin-top:5px;">
			
					                    </table>
			                        </div>
			                         <div title="体检记录">
			                            <table  id="look-patientsHealth-tab" style="width:520px;height:303px;margin-top:5px;">
			
					                    </table>
			                        </div>
			                        
			                    </div>
			          </div>
			         
			</div><!-- 切换面板结束 -->							
			
      </div>
     

    <input type="hidden" value="${user.userId}"  id="userId">
    <input type="hidden" value="${user.userName}"  id="userName">
  
<!-- 弹框提示 -->
<div id="saveclinic-win" class="easyui-window"  title="提示框" style="width:300px;height:156px"
    data-options="iconCls:'icon-save',modal:true,resizable:false,collapsible:false,maximizable:false,minimizable:false,closed:true">
          <p class="window-tishi" style=" margin-left: 72px;font-size: 16px;margin-top: 47px;">
          </p>
</div>
</body>
</html>